﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PH.Model.Systems;
using PH.Model;
namespace PH.Data.Systems
{
    public class SysLogCommand
    {
        public static SysLogCollection Gets(QueryBase sea)
        {
            var ret = new SysLogCollection();
            using (DBCentre db = new DBCentre())
            {
                IQueryable<SysLog> q = db.DataContext.SysLogs;
                var n = q.Count();
                if (n > 0)
                {
                    q = q.OrderByDescending(p => p.ID);
                    if (sea != null && sea.PageSize > 0)
                        q = q.Skip(sea.PageSize * sea.PageIndex).Take(sea.PageSize);
                    var lst = q.ToList();
                    ret = Convertor.ConvertCollection<SysLogModel, SysLog, SysLogCollection>(lst);
                    ret.TotalRecordsCount = n;
                }
            }
            return ret;
        }
    }
}
